axios.defaults.baseURL = ''
Vue.prototype.$http = axios
Vue.prototype.$echarts = window.echarts
Vue.config.productionTip = false
var app = new Vue({
    el: '#app',
    data() {
        return {
            chartInstance: null,
            allData: null
        }
    },
    mounted() {
        this.initChart()
        this.getData()
        window.addEventListener('resize', this.screenAdapter)
    },
    destoryed() {
        window.removeEventListener('resize', this.screenAdapter)
    },
    methods: {
        //初始化
        initChart() {
            this.chartIntstance = this.$echarts.init(this.$refs.pie_chart)
            const initOption = {}
            this.chartInstance.setOption(initOption)

        },
        //获取数据
        async getData() {
            var obj;
            const {
                data: ret
            } = await this.$http.get('')
            this.allDta = ret
            console.log(this.allData);
            // obj = ret.selectResult
            // console.log(obj);
            // this.allData = obj
            // console.log(this.allData);
            this.updateChart()
        },
        //更新列表
        updateChart() {
            const sellerNames = this.allData.map((item) => {
                return item.name
            })
            const seriesArr = this.allData.map((item) => {
                return {
                    type: 'pie',
                    radius: ['70%', '80%'],
                    color: '#0088cc',
                    label: {
                        normal: {
                            position: 'center'
                        }
                    }
                }
            })

            const dataOption = {
                series: [

                ]
            }
            this.chartInstance.setOption(dataOption)

        },
        //屏幕分配率 屏幕适配
        screenAdapter() {
            const adapterOption = {}
            this.chartInstance.setOption(adapterOption)
            this.chartInstance.resize()
        }
    }
})